package com.lyh.web.controller.system;

import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;

import com.lyh.common.core.domain.entity.SysDictData;
import com.lyh.common.enums.RelationTypeEnum;
import com.lyh.system.domain.req.*;
import com.lyh.system.domain.resp.SysTrendsItemResp;
import com.lyh.system.domain.resp.SysTrendsResp;
import com.lyh.system.domain.vo.AppUpdateVo;
import com.lyh.system.mapper.SysDictDataMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.lyh.common.annotation.Log;
import com.lyh.common.core.controller.BaseController;
import com.lyh.common.core.domain.AjaxResult;
import com.lyh.common.enums.BusinessType;
import com.lyh.system.domain.SysRelationValue;
import com.lyh.system.service.ISysRelationValueService;
import com.lyh.common.utils.poi.ExcelUtil;
import com.lyh.common.core.page.TableDataInfo;

/**
 * 【配置管理和资产管理】Controller
 *
 * @author lyh
 * @date 2023-04-26
 */
@Api( value = "配置管理和资产管理",description = "配置管理和资产管理")
@RestController
@RequestMapping("/system/value")
public class SysRelationValueController extends BaseController
{
    @Autowired
    private ISysRelationValueService sysRelationValueService;



    @Log(title = "资产管理修改保存", businessType = BusinessType.INSERT)
    @ApiOperation("资产管理")
    @PostMapping("/zcglSaveOrUpdate")
    public AjaxResult zcglSaveOrUpdate(@RequestBody ZCGLReq req)
    {
        return toAjax(sysRelationValueService.zcglSaveOrUpdate(req));
    }


    @ApiOperation("资产管理详情")
    @GetMapping("/zcglInfo")
    public AjaxResult zcglInfo()
    {
        return sysRelationValueService.zcglInfo();
    }



    @Log(title = "配置管理-报单返佣设置-每日修改保存", businessType = BusinessType.INSERT)
    @ApiOperation("报单返佣设置- 每日")
    @PostMapping("/bdSaveOrUpdateBdfy")
    public AjaxResult bdSaveOrUpdateBdfy(@Validated @RequestBody SysImmediatelyReq req) {
        return toAjax(sysRelationValueService.imSaveOrUpdateBdfy(req));
    }

    @ApiOperation("报单返佣详情(每日)")
    @GetMapping("/bdfyInfo")
    public AjaxResult bdfyInfo(){
        return sysRelationValueService.bdfyInfo();
    }

    @Log(title = "配置管理-报单返佣设置-会员修改保存", businessType = BusinessType.INSERT)
    @ApiOperation("报单返佣设置- 会员")
    @PostMapping("/bdSaveOrUpdateBdfyMember")
    public AjaxResult bdSaveOrUpdateBdfyMember(@Validated @RequestBody SysImmediatelyReq req){
        return toAjax(sysRelationValueService.imSaveOrUpdateBdfyMember(req));
    }

    @ApiOperation("报单返佣详情(会员分享收益)")
    @GetMapping("/bdfyInfoMember")
    public AjaxResult bdfyInfoMember(){
        return sysRelationValueService.bdfyInfoMember();
    }





    @Log(title = "配置管理-邀请返佣设置修改保存", businessType = BusinessType.INSERT)
    @ApiOperation("邀请返佣设置")
    @PostMapping("/yqSaveOrUpdate")
    public AjaxResult imSaveOrUpdateYQfy(@Validated @RequestBody SysYQFYReq req)
    {
        sysRelationValueService.imSaveOrUpdateYQfy(req);
        return success();
    }

    @ApiOperation("邀请返佣详情")
    @GetMapping("/yqfyInfo")
    public AjaxResult yqfyInfo()
    {
        return sysRelationValueService.yqfyInfo();
    }



    @Log(title = "配置管理-门店返佣设置修改保存", businessType = BusinessType.INSERT)
    @ApiOperation("门店返佣设置")
    @PostMapping("/mdSaveOrUpdate")
    public AjaxResult mdSaveOrUpdateYQfy(@Validated @RequestBody SysMDFYReq req)
    {
        sysRelationValueService.saveOrUpdateMdfy(req);
        return success();
    }

    @ApiOperation("门店返佣详情")
    @GetMapping("/mdfyInfo")
    public AjaxResult mdfyInfo()
    {
        return sysRelationValueService.mdfyInfo();
    }

    @Log(title = "配置管理-报单收益设置修改保存", businessType = BusinessType.INSERT)
    @ApiOperation("报单收益设置")
    @PostMapping("/bdSaveOrUpdate")
    public AjaxResult saveOrUpdateBdsy(@Validated @RequestBody SysAreaOrderReq req)
    {
        sysRelationValueService.saveOrUpdateBdsy(req);
        return success();
    }

    @ApiOperation("报单收益详情")
    @GetMapping("/bdsyInfo")
    public AjaxResult bdsyInfo()
    {
        return sysRelationValueService.bdsyInfo();
    }

    @ApiOperation("轮播图上传")
    @PostMapping("/bannerSaveOrUpdate")
    public AjaxResult bannerSaveOrUpdate(@Validated @RequestBody SysBannerImgaeReq req)
    {
        sysRelationValueService.bannerSaveOrUpdate(req);
        return success();
    }

    @ApiOperation("轮播图设置")
    @PostMapping("/bannerImageSet")
    public AjaxResult setBannerImage(@Validated @RequestBody SysBannerImgaeReq req)
    {
        sysRelationValueService.setBannerImage(req);
        return success();
    }


    @ApiOperation("轮播图详情")
    @GetMapping("/bannerImageInfo")
    public AjaxResult bannerImageInfo()
    {
        return sysRelationValueService.getBannerInfo();
    }


    @ApiOperation("轮播图APP详情")
    @GetMapping("/bannerImageInfoByApp")
    public AjaxResult bannerImageInfoByApp()
    {
        return AjaxResult.success(sysRelationValueService.getAppBannerInfo());
    }


    @Log(title = "轮播图删除", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    @ApiOperation(value = "轮播图删除")
    public AjaxResult deleteBannerById(@PathVariable Long id)
    {
        return toAjax(sysRelationValueService.deleteBannerById(id));
    }

    @ApiOperation("app更新信息")
    @GetMapping("/appUpdate")
    public AjaxResult appUpdate()
    {
        AppUpdateVo appUpdate = sysRelationValueService.getAppUpdate();
        return AjaxResult.success(appUpdate);
    }








}
